package com.xsprite.managesys.service;


public class LogAnalyzer {
	
	public static String analyze(String logInfo){
		try{
			
			if(logInfo.indexOf("money+=")!=-1){
				String[] infos = logInfo.split("\\+=");
				return "获得了" + infos[1] + "银两";
			} else if(logInfo.indexOf("money-=")!=-1){
				String[] infos = logInfo.split("\\-=");
				return "减少了" + infos[1] + "银两";
			} else if(logInfo.indexOf("shengwang+=")!=-1){
				String[] infos = logInfo.split("\\+=");
				return "获得了" + infos[1] + "声望";
			} else if(logInfo.indexOf("shengwang-=") != -1){
				String[] infos = logInfo.split("\\-=");
				return "减少了" + infos[1] + "声望";
			} else if(logInfo.indexOf("rongyu+=") != -1){
				String[] infos = logInfo.split("\\+=");
				return "获得了" + infos[1] + "荣誉";
			} else if(logInfo.indexOf("gangContribute+=") != -1){
				String[] infos = logInfo.split("\\+=");
				return "获得了" + infos[1] + "帮贡";
			} else if(logInfo.indexOf("zhenqi+=") != -1){
				String[] infos = logInfo.split("zhenqi+=");
				return "获得了" + infos[1] + "真气";
			} else if(logInfo.indexOf("+=")!=-1){
				String[] infos = logInfo.split("\\+=");
				String name = XlsxFileManager.getInstance().getItemById(Integer.parseInt(infos[0]));
				if(name == null){
					return logInfo;
				}
				return "获得了" + infos[1] + "个" + name;
			} else if (logInfo.indexOf("-=") != -1){
				String[] infos = logInfo.split("\\-=");
				String name = XlsxFileManager.getInstance().getItemById(Integer.parseInt(infos[0]));
				if(name == null){
					return logInfo;
				}
				return "减少了" + infos[1] + "个" + name;
			}
		} catch (Exception ex){
			return logInfo;
		}
		
		return logInfo;
	}
	
	public String getAddEquipLogStr(int equipId){
		String result = equipId + "+=1";
		return result;
	}
	
	public String getAddTokenPropLogStr(int tokenPropId){
		String result = tokenPropId + "+=1";
		return result;
	}
	
	public String getAddPropLogStr(int propId, int count){
		String result = propId + "+=" + count;
		return result;
	}
	
	public String getRemoveEquipLogStr(int equipId){
		String result = equipId + "-=1";
		return result;
	}
	
	public String getRemoveTokenPropLogStr(int tokenPropId){
		String result = tokenPropId + "-=1";
		return result;
	}
	
	public String getRemovePropLogStr(int propId, int count){
		String result = propId + "-=" + count;
		return result;
	}
	
	public String getAddShengwangLogStr(int count){
		String result = "shengwang+=" + count;
		return result;
	}
	
	public String getReduceShengwangLogStr(int count){
		String result = "shengwang-=" + count;
		return result;
	}
	
	public String getAddMoneyLogStr(int count){
		String result = "money+=" + count;
		return result;
	}
	
	public String getReduceMoneyLogStr(int count){
		String result = "money-=" + count;
		return result;
	}
	
	public String getAddGangExpLogStr(int count, int totalCount){
		String result = "+=" + count + "," + totalCount;
		return result;
	}
	
	public String getAddZhanqiLogStr(long gangId, int count, int totalCount){
		String result = "+=" + gangId + "," + count + "," + totalCount;
		return result;
	}
	
	public String getUpGangLevelLogStr(long gangId, int level){
		String result = gangId + "=" + level;
		return result;
	}
	
	public String getLockEquipLogStr(long equipId, int modelId){
		String result = "0=" + equipId + "," + modelId;
		return result;
	}
	
	public String getWulinLastRoundRewardLogStr(int[] goodsType, int[] goodsNum){
		StringBuffer sb = new StringBuffer();
		int len = goodsType.length;
		sb.append("+=");
		for(int i = 0; i < len; i++){
			sb.append(goodsType[i] + "," + goodsNum[i] + ",");
		}
		String result = sb.substring(0, sb.length() - 1);
		return result;
	}
	
	public String getAddPublicGangFightLogStr(long gangId){
		String result = "+=" + String.valueOf(gangId);
		return result;
	}
	
	public String getRemovePublicGangFightLogStr(long gangId){
		String result = "-=" + String.valueOf(gangId);
		return result;
	}
	
	public String getKickFromTeamLogStr(long beKickedPlayerId, long captainId, long teamId){
		String result = "-=" + beKickedPlayerId + "," + captainId + "," + teamId;
		return result;
	}
	
	public String getExitFromTeamLogStr(long captainId, long teamId){
		String result = "-=" + captainId + "," + teamId;
		return result;
	}
	
	public String getJieShanTeamLogStr(long captainId, long teamId){
		String result = "-=" + captainId + "," + teamId;
		return result;
	}
	
	public String getStartMenpaiFightLogStr(long toPlayerId, byte isSuccess){
		String result = toPlayerId + "," + isSuccess;
		return result;
	}
	
	public String getExecuteMenPaiFightLogStr(long playerId, long toPlayerId, int place, boolean isSuccess){
		String result = playerId + "," + toPlayerId + "," + place + "," + (isSuccess==true?"1":"0");
		return result;
	}
	
	public String getTeamAreaFightLogStr(long playerId, long toPlayerId, byte isSuccess){
		String result = playerId + "," + toPlayerId + "," + isSuccess;
		return result;
	}
	
	public String getAddZuDuiLianShengLogStr(int currentLianshenNum, boolean isVictor){
		String result = currentLianshenNum + "," + (isVictor == true?"1":"0");
		return result;
	}
}
